import globals from "globals"
import pluginJs from "@eslint/js" // 校验js的规范(推荐)
import tseslint from "typescript-eslint" // 推荐的ts规范
import pluginVue from "eslint-plugin-vue" //推荐的vue规范
import prettierRecommended from "eslint-plugin-prettier/recommended"

//消除eslint 对于全局导入的警告
import { createRequire } from "module"
const require = createRequire(import.meta.url)
const autoImport = require("./.eslintrc-auto-import.json")

/** @type {import('eslint').Linter.Config[]} */
export default [
  { files: ["**/*.{js,mjs,cjs,ts,vue}"] },
  {
    languageOptions: {
      globals: { ...globals.browser, ...globals.node, ...autoImport.globals }
    }
  },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  ...pluginVue.configs["flat/essential"],
  {
    files: ["**/*.vue"], //校验vue中的ts代码
    languageOptions: { parserOptions: { parser: tseslint.parser } }
  },
  // eslint 主要是验证代码规范  prettier格式化代码
  {
    rules: {
      "no-console": "warn",
      semi: "error",
      "vue/multi-word-component-names": ["off"]
    }
  },
  prettierRecommended //覆盖eslint的规范
]
